package com.polaris.live.viewmodel

import androidx.lifecycle.MutableLiveData
import com.polaris.live.common.cacha.UserManager
import com.polaris.live.common.mvvm.viewmodel.BaseViewModel
import com.polaris.live.common.network.request
import com.polaris.live.common.network.state.ResultState
import com.polaris.live.common.resp.UserResp
import com.polaris.live.common.util.ToastGravity
import com.polaris.live.net.liveService
import com.polaris.live.net.userService
import com.polaris.live.resp.back_resp.LiveSubsidyIndicatorResp
import com.polaris.live.resp.go_resp.OtherUserIdBean
import com.polaris.live.translation.R

/**
 * 测试页面
 *
 * @author Created by lucas on 2023/12/25 07:02
 * @since 1.0.0
 */
class TestViewModel : BaseViewModel() {

    fun addFollower(otherId: Long) {
        request({ userService.addFollower(OtherUserIdBean(otherId)) }, {
            ToastGravity.showGravity(R.string.follower_succeed)
        })
    }

    var userLiveData = MutableLiveData<UserResp>()
    fun getUser() {
        request({ userService.getUserData() }, {
            UserManager.setUser(it)
            userLiveData.value = it
        })
    }

    val resp = MutableLiveData<ResultState<LiveSubsidyIndicatorResp>>()
    fun getData() {
        request({ liveService.subsidies() }, resp)
    }
}